<?php

namespace App\Http\Controllers\WebApi\Common;

use Illuminate\Http\Request;
use App\Http\Controllers\WebApi\Common\BaseController as Controller;
use App\Http\Service\CommonService;
class CommonController extends Controller{
    
    protected $service;

    public function __construct()
    {
        parent::__construct();
        $this->service = new CommonService();
    }
    
    public function test(){
        return "test common";
    }
    /**zwp
     * 根据产品名称获取产品分类
     * @param Request $request
     * @return json
     */
    public function getCategory(Request $request){
        $name = $request->name;
        //$name = "围巾";
        $data = $this->service->getCategoryByName($name);
        if(!$data){
            return $this->toJson(-3);
        }
        return $this->success($data);
    }
    /**zwp
     * 获取地区
     * @return json
     */
    public function getArea(){
        $data = $this->service->getArea();
        if(!$data){
            return $this->toJson(-3);
        }
        return $this->success($data);
    }
    
    public function getJobs(){
        $data = $this->service->getJobs();
        if(!$data){
            return $this->toJson(-3);
        }
        return $this->success($data);
    }
}
